package cn.felord.common.http;


import cn.felord.common.utils.AuthenticationUtil;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;

import java.util.Collection;

/**
 * The type Base controller.
 *
 * @author n1
 * @since 2021 /4/12 15:00
 */
public abstract class BaseController {

    /**
     * 查询当前用户的认证对象
     *
     * @return the authentication
     */
    public Authentication currentUser() {
        return AuthenticationUtil.currentUser();
    }

    /**
     * 查询当前用户的用户角色权限信息
     *
     * @return the collection
     */
    public Collection<? extends GrantedAuthority> currentUserRoles() {
        return AuthenticationUtil.currentUserRoles();
    }

    /**
     * 查询当前用户的账户名
     *
     * @return the string
     */
    public String currentUserName() {
        return AuthenticationUtil.currentUserName();
    }
}
